<template>
	<view style="padding: 15px;">
		<view style="width: 100%; min-height: 50vh;">
			<view style="word-break:break-all;">{{resultInfo}}</view>
			<image :src="imageUrl" mode="aspectFit" style="width: 100%; height: 300rpx;"></image>
			<video :src="videoUrl"></video>
		</view>
		<view class="btns">
			<button type="primary" @click="testGetLocation">testGetLocation</button>
			<button type="primary" @click="testScanCode">testScanCode</button>
			<button type="primary" @click="testChooseImage">testChooseImage</button>
			<button type="primary" @click="testChooseVideo">testChooseVideo</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				resultInfo: '',
				imageUrl: '',
				videoUrl: ''
			}
		},
		methods: {
			testGetLocation() {
				this.resultInfo = ''
				this.$appApi('getLocation').then(res => {
					this.resultInfo = JSON.stringify(res)
				}).catch(err => {
					this.resultInfo = JSON.stringify(err)
				})
			},
			testScanCode() {
				this.resultInfo = ''
				this.$appApi('scanCode').then(res => {
					this.resultInfo = JSON.stringify(res)
				}).catch(err => {
					this.resultInfo = JSON.stringify(err)
				})
			},
			testChooseImage() {
				let token = uni.getStorageSync('_jeeidp_token');
				let param = {
					serverUrl: 'https://xxx/api/common/uploadFile',
					header: {
						Authorization: token
					}
				}
				this.$appApi('chooseImage', param).then(res => {
					this.resultInfo = JSON.stringify(res)
					this.imageUrl = this.$util.showFile(res)
				}).catch(err => {
					this.resultInfo = JSON.stringify(err)
				})
			},
			testChooseVideo() {
				let token = uni.getStorageSync('_jeeidp_token');
				let param = {
					serverUrl: 'https://xxx/api/common/uploadFile',
					header: {
						Authorization: token
					}
				}
				this.$appApi('chooseVideo', param).then(res => {
					this.resultInfo = JSON.stringify(res)
					this.videoUrl = this.$util.showFile(res)
				}).catch(err => {
					this.resultInfo = JSON.stringify(err)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.btns {
		button {
			margin-bottom: 15px;
		}
	}
</style>
